package rolesystem.agentlogic.GUI;

import java.awt.Dimension;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;

public class StatePanel extends JScrollPane 
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8133729542873545366L;
	private JEditorPane editorPane;
	public JScrollPane editorScrollPane;
	
	public StatePanel() 
	{	
		super();
		
		editorPane = createEditorPane();
		
		this.setViewportView(editorPane);
                
        this.setVerticalScrollBarPolicy(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        this.setPreferredSize(new Dimension(250, 145));
        this.setMinimumSize(new Dimension(10, 10));
	}
	
	
    private JEditorPane createEditorPane() 
    {
        JEditorPane editorPane = new JEditorPane();
        editorPane.setEditable(false);
        editorPane.setText("");
       
        return editorPane;
    }
    
    public void append(String s) 
    {
    	   try {
    	      Document doc = editorPane.getDocument();
    	      doc.insertString(doc.getLength(), s+System.getProperty("line.separator"), null);
    	   } catch(BadLocationException exc) {
    	      exc.printStackTrace();
    	   }
    }
    
    public void reset() 
    {
    	editorPane.setText(null);
    }
    
    
	
	
}
